﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity;
using System.Linq;
using System.Web;

namespace WCLOnlineExam.Models
{
    //[EntityAuthentication(AllowAnonymous = false, ViewRolesRequired = new string[] { "Admin" })]
    [ParentAttribute(typeof(UserGroup), "Group")]
    [DisplayColumn("UserName", "UserName")]
    public class User : UserBase
    {

        [Required]
        public virtual string UserName { get; set; }

        [Display(Name = "名称", Order = 10)]
        [Required]
        public virtual string Name { get; set; }

        [Display(Name = "所属组", Order = 70)]
        [Required]
        public virtual UserGroup Group { get; set; }

        [Display(Name = "电子邮件", Order = 70)]
        public virtual string Email { get; set; }

        [Display(Name = "联系电话", Order = 60)]
        public virtual string Phone { get; set; }

        [Hide(IsHiddenOnEdit = true)]
        [Display(Name = "状态", Order = 70)]
        public virtual Status enabled { get; set; }


        public override bool IsInRole(string role)
        {
            return Group.Power.ToString() == role;
        }
    }
    public enum Status
    {
        Enable = 1,
        Disabled = 0
    }
}